package com.lzm.ydpt.module.mall.activity;

import android.view.View;

import com.byt.framlib.base.BaseActivity;
import com.byt.framlib.baseadapter.rv.RvCommonAdapter;
import com.byt.framlib.baseadapter.rv.RvViewHolder;
import com.byt.framlib.commonwidget.LoadingTip;
import com.byt.framlib.commonwidget.NormalTitleBar;
import com.byt.framlib.commonwidget.OnNoDoubleClickListener;
import com.byt.framlib.commonwidget.refresh.RefreshHeaderView;
import com.lzm.ydpt.R;
import com.lzm.ydpt.entity.mall.ProductBean;
import com.lzm.ydpt.mvp.contract.DiscountActionContract;
import com.lzm.ydpt.mvp.presenterimpl.DiscountActionPresenterImpl;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

/**
 * 优惠活动
 */
public class DiscountActionActivity extends BaseActivity<DiscountActionPresenterImpl> implements DiscountActionContract.View {

    @BindView(R.id.ntb_discount_action)
    NormalTitleBar ntb_discount_action;
    @BindView(R.id.ltp_discount_action)
    LoadingTip ltp_discount_action;
    @BindView(R.id.srf_discount_action)
    SmartRefreshLayout srf_discount_action;
    @BindView(R.id.rv_discount_action)
    RecyclerView rv_discount_action;
    private RvCommonAdapter<ProductBean> commonAdapter = null;
    private List<ProductBean> sproBeans = new ArrayList<>();

    @Override
    public int getLayoutId() {
        return R.layout.activity_discount_action;
    }

    @Override
    public DiscountActionPresenterImpl initPreData() {
        return new DiscountActionPresenterImpl(this);
    }

    @Override
    public void initView() {
        setNtbTitle(ntb_discount_action, true);
        ntb_discount_action.setTitleText("优惠活动");
        ntb_discount_action.setOnBackListener(new OnNoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                finish();
            }
        });
        initRefrsh();
        initAdapter();

    }

    private void initRefrsh() {
        setRefreshLayout(srf_discount_action);
        srf_discount_action.setEnableRefresh(true);
        srf_discount_action.setEnableLoadMore(false);
        srf_discount_action.setRefreshHeader(new RefreshHeaderView(mBContext).getHeaderStyleStaffF4());
        srf_discount_action.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {

            }

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {

            }
        });
    }

    private void initAdapter() {
        sproBeans.add(new ProductBean());
        sproBeans.add(new ProductBean());
        sproBeans.add(new ProductBean());
        sproBeans.add(new ProductBean());
        sproBeans.add(new ProductBean());
        rv_discount_action.setLayoutManager(new LinearLayoutManager(mBContext));
        commonAdapter = new RvCommonAdapter<ProductBean>(mBContext, sproBeans, R.layout.item_discount_action_rv) {
            @Override
            protected void convert(RvViewHolder holder, ProductBean shopInfoBean, int position) {
//                holder.setText(R.id.tv_action_msg_state,"");
//                holder.setText(R.id.tv_action_msg_time,"");
//                holder.setText(R.id.tv_action_msg_titile,"");
//                holder.setText(R.id.tv_action_msg_jump,"");
//                ImageLoaderUtils.display(holder.getView(R.id.img_action_msg_ablum),"");
//                holder.getConvertView().setOnClickListener(new OnNoDoubleClickListener() {
//                    @Override
//                    protected void onNoDoubleClick(View v) {
//                        showShortToast("订单详情");
//                    }
//                });
            }
        };
        rv_discount_action.setAdapter(commonAdapter);
    }


    @Override
    public void showMessage(String message, String method) {

    }

    @Override
    public void showErrorView(String msg) {

    }


    @Override
    public void onDiscountAction() {

    }
}
